//
//  TYDataSolidify.m
//  AngerDragon
//
//  Created by gaotime_macbook_2 on 11-12-17.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TYDataSolidifySingleton.h"
#import "cocos2d.h"

@implementation TYDataSolidifySingleton

static TYDataSolidifySingleton *myInstance = nil;



/// ios实现单例, 要这样做, 因为没有私有构造的概念
+(id)alloc {
	NSAssert(myInstance == nil, @"Attempted to allocate a second instance of a singleton.");
	return [super alloc];
}



/*
+ (id) new {
 return [self alloc];
}
+ (id) hiddenAlloc {
 return [super alloc];
}
 
+ (id) copyWithZone:(NSZone *)zone {
	return [self alloc];
}

- (id) copyWithZone:(NSZone *) zone {
	// - copy inherited from NSObject calls -copyWithZone:
	NSLog(@"TYDataSolidifySingleton: attempt to -copy may be a bug.");
	[self retain];
	return self;
}

- (id) mutableCopyWithZone:(NSZone *) zone {
	/// -mutableCopy inherited from NSObject calls -mutableCopyWithZone:
	return [self copyWithZone:zone];
}

+ (void) attemptDealloc {
	if ([myInstance retainCount] != 1) {
		return;
	}
	
	[myInstance release];
	myInstance = nil;
}

+ (BOOL) sharedInstanceExists {
	return (nil != myInstance);
}
*/


/// 单例方法
+ (id<TYDataSolidifyProtocol>) sharedInstance {
	if (nil == myInstance) {
		 		
		myInstance = [[[self class] alloc] init];
	}
	
	return myInstance;
}



- (id) init {
	
	if ((self = [super init])) {
		CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
		
	
	}
	
	return self;
}

- (void) dealloc {
	CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
	
	/// 
	myInstance = nil;
	 
	
	[super dealloc];
}

#pragma mark 实现数据固化接口的相关方法
- (void) deallocMe {
	[self dealloc];
}
@end
